package com.icinfo.cloud.provider.punish.api.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.util.ObjectUtils;

/**
 * 描述：案件移送性别枚举类
 *
 * @author zhengqiang
 * @description
 * @date 2022/9/26
 */
@AllArgsConstructor
@Getter
public enum TransferSexEnum {
    /**
     * 案件移送性别枚举类
     */
    MAN("1", "男"),
    WOMAN("2", "女"),
    UNKNOWN_SEX("0", "未知的性别"),
    UNSPECIFIED_SEX("9", "未说明的性别");

    /**
     * 编码
     */
    private String code;
    /**
     * 描述
     */
    private String des;

    /**
     * 描述：根据名称获取code
     *
     * @param des des
     * @return {@link String }
     * @date 2022/9/26
     */
    public static String getCodeByDes(String des) {
        if (ObjectUtils.isEmpty(des)) {
            return TransferSexEnum.UNSPECIFIED_SEX.getCode();
        }
        for (TransferSexEnum e : TransferSexEnum.values()) {
            if (des.equals(e.getDes())) {
                return e.getCode();
            }
        }
        return TransferSexEnum.UNSPECIFIED_SEX.getCode();
    }

}
